@echo off
setlocal enabledelayedexpansion

chcp 437

for /f "tokens=2 delims=: " %%I in ('netsh wlan show interfaces ^| findstr /c:"Name"') do (
    set "interface=%%I"
)

for /f "tokens=3" %%G in ('netsh interface ip show addresses "%interface%" ^| findstr /c:"Default Gateway"') do (
    set "gateway=%%G"
)

echo %interface% Gateway IP address: %gateway%

@REM netsh interface ipv4 set dns name="Wi-Fi" source=dhcp
@REM netsh interface ipv4 add dns name="Wi-Fi" addr=!gateway! index=1
netsh interface ipv4 set dns name="%interface%" static %gateway% primary

echo DNS设置完成！

endlocal